/**   
* @Title: UserAction.java 
* @Package com.awei.eshop.modules.user.web.action 
* @Description: TODO(用一句话描述该文件做什么) 
* @author awei  
* @date Sep 21, 2015 12:22:32 AM 
* @version V1.0   
*/
package com.awei.ssh2boot.modules.user.web.action;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.apache.log4j.Logger;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import com.alibaba.fastjson.JSON;
import com.awei.ssh2boot.common.base.BaseAction;
import com.awei.ssh2boot.modules.user.po.User;
import com.awei.ssh2boot.modules.user.service.UserService;

/** 
 * @ClassName: UserAction 
 * @Description: TODO(这里用一句话描述这个类的作用) 
 * @author 刘亚伟
 * @Copyright  伟佳科技有限责任公司
 * @date 2015 Sep 21, 2015 12:22:32 AM 
 */
@Controller
@Namespace("/user")
@ParentPackage(value = "ssh2-default")
public class UserAction extends BaseAction {
	private static final Logger logger = Logger.getLogger(UserAction.class);
	
	@Autowired
	private UserService userService;
	
	private List<User> userlist;
	private String userlist2json;
	
	public String getUserlist2json() {
		return userlist2json;
	}

	public void setUserlist2json(String userlist2json) {
		this.userlist2json = userlist2json;
	}

	public List<User> getUserlist() {
		return userlist;
	}

	public void setUserlist(List<User> userlist) {
		this.userlist = userlist;
	}

	@Action("findall")
	public String findAll() {
		userlist = userService.findAll();
		Iterator<User> itUser = userlist.iterator();
		while(itUser.hasNext()) {
			User user = itUser.next();
			logger.info("每一个user："+JSON.toJSONString(user));
		}
		
		userlist2json= JSON.toJSONString(userlist);		//将userlist封装成字符串
		logger.info(userlist2json);
		return SUCCESS;
	}
}
